/*** 获取文章内容 begin */
// 获取参数
var w  =$(document).width()
$('#bill').css('left',(w-580)/2 + 'px')
$(window).resize(function() {
    var w  =$(document).width()
    $('#bill').css('left',(w-580)/2 + 'px')
});
function GetQueryString(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return '';
}
// 切换页面
$('.nav_wrapper ul.nav a').click(function(ev) {
  ev.preventDefault();
  var $this = $(this);
  var index = $this.data('index');
  // if (index == 2) {
  //   headtipObj2.show('该功能仅对高级版/企业版充值用户开放')
  // } else {
    $('.nav_wrapper ul.nav a').removeClass('active');
    $this.addClass('active');
    $('.setting_wrapper .setting_content').addClass('hide');
    $('.setting_wrapper .setting_content[data-index="' + index +'"]').removeClass('hide');
  // }
})

var pageIndex = GetQueryString('type') ? GetQueryString('type') : 0;
$('.nav_wrapper ul.nav a[data-index="' + pageIndex + '"]').trigger('click');

$('.popup .close').click(function () {
  $('.popup').addClass('hide');
})
$('.popup').click(function () {
  $(this).addClass('hide');
})

$('.popup > .inner').click(function (ev) {
  ev.stopPropagation();
})

$('#change-email').click(function (ev) {
  $('.popup.popup-change-email').removeClass('hide');
})

$('#change-password').click(function (ev) {
  var oldpw = $('.popup-change-password input.oldpassword').val(''),
  newpw1 = $('.popup-change-password input.newpassword').val(''),
  newpw2 = $('.popup-change-password input.newpassword2').val('');
  $('.popup-change-password .popup-error').text('');
  $('.popup.popup-change-password').removeClass('hide');
})

$('.clickServer').click(function(e){
	e.stopPropagation();
	if( $('.server').css('display') == 'none' ){
		$('.server').css({'display':'block'})
		$('.mine').css({'display':'none'})
	}else{
		$('.server').css({'display':'none'})
	}
})
// 获取主体信息
// var token = localStorage.getItem('token');
$('.user_img').click(function(e){
	e.stopPropagation();
	if( $('.mine').css('display') == 'none' ){
		$('.mine').css({'display':'block'})
		$('.server').css({'display':'none'})
	}else{
		$('.mine').css({'display':'none'})
	}
})
$('body').click(function() {
  $('.mine').hide();
  $('.server').hide();
})

// 设置改变主体项
pressSelect.init();
// 设置个人信息项
personInfo.init(function () {}, function (data) {
  // 设置不同主播价格
	// 设置邮箱
  // $('.mask_footer_e').text(data.data.email);
  $('.popup-change-email .email input').val(data.data.email);
  $('.setting_wrapper .username').text(data.data.username);
  // 设置余额
  $('.info_set .info_inner.balance >span').text(data.data.balance + ' 元');
  // 判断是否绑定微信
  if (data.data.iswechat == 0) {
    // 未绑定微信
    $('.setting_wrapper .wechat').html('<a href="#" class="btn" id="bind-wechat">绑定微信</a>')
  } else {
    // 已绑定微信
    $('.setting_wrapper .wechat').html("<span class='tip light-gray'>已绑定</span><a href='#' class='btn' id='unbind-wechat'>解除绑定</a>")
  }
  // 修改账户余额
  console.log(data.data.balance);
  $('.setting_wrapper .balance .tip').text(data.data.balance + ' 元');
  calVars={
      mediaEmail:data.data.email
  }
});
// var mediaInfo = 'http://testmedia.heardtech.com/Post/Mediainfo';
// $.post(mediaInfo, {
// 	token: localStorage.getItem('token')
// }, function (data) {
// 	// 返回数据
// 	if ('000000' != data.code) return;
// 	var html = `<ul>
// 		<li class="font1">
// 			<span class="font">` +
// 			data.data.media_name +
// 			`</span>
// 		</li>
// 		<li class="line"></li>
// 		<li class="font2">
// 			<span class="font">基础版</span>
// 			<span class="font font3">升级</span>
// 		</li>
// 		<li class="font1 mineEmail">
// 			<span class="font">` +
// 			data.data.email
// 			+ `</span>
// 		</li>
// 		<li class="line"></li>
// 		<li class="hover point font5">
// 			<a href="setting.html">
// 				<span class="font">账号设置</span>
// 			</a>
// 		</li>
// 		<li class="line"></li>
// 		<li class="hover point font5">
// 			<span class="font">邀请好友</span>
// 		</li>
// 		<li class="hover point font5">
// 			<span class="font">推荐主播</span>
// 		</li>
// 		<li class="hover point font5">
// 			<span class="font">使用帮助</span>
// 		</li>
// 		<li class="line"></li>
// 		<li class="hover point font5 logout">
// 			<span class="font">退出登录</span>
// 		</li>
// 	</ul>`;
// 	$('.header_item .boxShow.mine').html(html);
// 	// 设置不同主播价格
// 	// 设置邮箱
//   // $('.mask_footer_e').text(data.data.email);

//   $('.popup-change-email .email input').val(data.data.email);
//   $('.setting_wrapper .username').text(data.data.username);

//   // 判断是否绑定微信
//   if (data.data.iswechat == 0) {
//     // 未绑定微信
//     $('.setting_wrapper .wechat').html('<a href="#" class="btn" id="bind-wechat">绑定微信</a>')
//   } else {
//     // 已绑定微信
//     $('.setting_wrapper .wechat').html(`
//     <span class="tip light-gray">已绑定</span>
//     <a href="#" class="btn" id="unbind-wechat">解除绑定</a>
//     `)
//   }

//   // 修改账户余额
//   $('.setting_wrapper .balance .tip').text(data.data.balance + ' 元');
// })

$('.setting_wrapper').delegate('#bind-wechat', 'click', function (ev) {
  // 绑定微信按钮
  console.log('绑定微信');
})
$('.setting_wrapper').delegate('#unbind-wechat', 'click', function (ev) {
  // 绑定微信按钮
  console.log('解绑微信');
})

// $('.boxShow.mine').delegate('.logout', 'click', function (e) {
// 	e.stopPropagation();
// 	localStorage.removeItem('token');
// 	window.location.href="logIn/index.html";
// })

$('.popup-change-password input').on('keydown', function () {
  $('.popup-change-password .popup-error').text('');
})
// 修改密码弹窗
$('.popup-change-password .btn-confirm').click(function (ev) {
  // var api = 'http://testmedia.heardtech.com/Post/UpdatePassword';
  var api = apiCollect.apiPWUpdate;
  var oldpw = $('.popup-change-password input.oldpassword').val(),
    newpw1 = $('.popup-change-password input.newpassword').val(),
    newpw2 = $('.popup-change-password input.newpassword2').val();
  if (!oldpw) {
    // headtipObj.show('字段不能为空');
    $('.popup-change-password .popup-error').text('旧密码不能为空');
  } else if (!newpw1 || !newpw2) {
    $('.popup-change-password .popup-error').text('新密码不能为空');
  } else if (newpw1 != newpw2) {
    // headtipObj.show('新密码两次输入不一致');
    $('.popup-change-password .popup-error').text('两次输入的密码不一致');
  } else {
    $.post(api, {
      token: localStorage.getItem('token'),
      oldpassword: oldpw,
      newpassword: newpw1
    }, function (data) {
      if (data.code == '000000') {
        headtipObj2.show('修改成功');
        $('.popup .close').trigger('click');
      } else {
        // headtipObj.show(data.message);
        $('.popup-change-password .popup-error').text(data.message);
      }
    })
  }
})

// 修改邮箱弹窗
$('.popup-change-email .btn-confirm').click(function(ev) {
  // var api = 'http://testmedia.heardtech.com/Post/UpdateEmail';
  var api = apiCollect.apiEmailUpdate;
  var email = $('.popup-change-email input').val();
  $.post(api, {
    token: localStorage.getItem('token'),
    email: email
  }, function (data) {
    if (data.code == '000000') {
      headtipObj2.show('修改成功');
      $('.popup .close').trigger('click');
      $('.boxShow.mine .mineEmail').html('<span class="font">' + email + '</span>');
    } else {
      headtipObj.show(data.message);
    }
  })
})

// 未开放功能提醒
$('.btn-fake').click(function (ev) {
  headtipObj.show('该功能暂未开放');
})

// 主体列表功能
// var objListApi = 'http://testmedia.heardtech.com/Post/SelectMedia';
var objListApi = apiCollect.apiMediaList;
$.post(objListApi, {
  wid: localStorage.getItem('wid')
}, function (data) {
  if (data.code == '000000') {
    var html = '';
    var item;
    for (var i = 0; i <data.data.length; i++) {
      item = data.data[i];
      html += "<tr id='media_" + item.token_key 
      html += "' data-img='" + item.media_pic 
      html += "' data-email='"  + item.email 
      html += "' data-demand='" + item.media_demand 
      html += "' data-demand-name='"  + item.media_demand_name 
      html += "' data-message='" + item.media_message 
      html += "' data-name='" + item.media_name 
      html += "'><td>" + item.media_name 
      html += "</td><td width='87'><span>"  
      if( item.collectpower == '1' ){
        html += item.wordnumber
      }else{
        html += '0' 
      }
      

      html +=  "</span></td><td>"  + item.email 
      html += "</td><td><a href='#' class='btn btn-edit' data-id='" + item.token_key + "'>编辑</a></td></tr>";
    }
    $('.obj_set').html(html);
  } else {
    headtipObj.show(data.message);
  }
})

//钱包data
var objWalletApi = apiCollect.apiGetIncome;
$.ajax({
    url:objWalletApi,
    type:"POST",
    data:{
        wid: localStorage.getItem('wid')
    },
    success:function (data) {
      if (data.code == '000000') {
          var html = '';
          var item;
          var arrType = ['支付宝充值','对公转账','余额支付','微信支付','支付宝支付','','','余额退款','微信退款', '支付宝退款'];
          var arrPayType = ['充值','充值','支付','支付','支付','','','退款','退款','退款'];
          var addPop = ['+','+','-','-','-','','','+','+','+'];
          for (var i = 0;i < data.data.list.length;i++){
              item = data.data.list[i];
              // html += `
              //     <tr>
              //       <td>`+item.creationtime+`</td>
              //       <td>`+arrPayType[item.status-1]+`</td>
              //       <td>`+arrType[item.status-1]+`</td>
              //       <td>`+item.number+`</td>
              //       <td>`+ addPop[item.status-1] +` `+item.money+`</td>
              //     </tr>
              // `;
              html += "<tr><td>" +item.creationtime+ "</td><td>" +arrPayType[item.status-1]+ "</td><td>" +arrType[item.status-1]+ "</td><td>" +item.number+ "</td><td>" + addPop[item.status-1] +" "+item.money+"</td></tr>";
          }
          $('.obj_set1').html(html);
          $('#yue').children('span').text(data.data.balance);
          $('#jine').children('span').text(data.data.invoice);
      }
    }
})

$('.setting_table_wrapper').delegate('.object-add-btn .btn', 'click', function(ev) {
  // 新建
  // $('.popup-change-object').removeClass('hide');
  $('.popup-change-object').attr("data-id", 'new').removeClass('hide');
    var html = "<div class='body'><div class='avatar'><div class='avatar-mask' id='img-uploader' style='position: relative; z-index: 1;'><span>LOGO</span></div></div><div class='line'><input type='text' placeholder='主体名称 如：好奇心日报' id='edit_media_name'></div><div class='line'><div class='input placeholder input-simulator'><span>选择需求 / 所属行业</span><b class='littleSiggle'></b></div><div class='dropDown hide'><ul><li data-value='1'>自媒体配音 / 公众号</li><li data-value='2'>短视频配音 / 视频业</li><li data-value='3'>有声书配音 / 出版业</li><li data-value='4'>内容付费配音 / 文化</li><li data-value='5'>教材培训配音 / 课件</li><li data-value='6'>外语配音 / 英文</li><li data-value='7'>模仿配音 / 名人</li></ul></div></div><div class='line'><input type='text' placeholder='用于接受音频的邮箱地址' id='edit_media_email' value='"+calVars.mediaEmail+"'></div><div class='line'><input type='text' placeholder='一句话简单介绍该主体' id='edit_media_text'></div><div class='popup-footer'><a href='#' class='btn btn-black btn-confirm'>提交</a><a href='#' class='btn btn-normal close'>取消</a></div></div>";
    $('#popup-change-object .body').html(html);
      $('#popup-change-object .close').on('click', function () {
        $('.popup').addClass('hide');
      })
      $('#popup-change-object .btn-confirm').on('click', function () {
        editData.create();
      })
      $('#popup-change-object .avatar-mask').click(function () {
        $('#img-uploader').trigger('click');
      })
  initSelector('.input-simulator');
})

$('.obj_set').delegate('.btn-edit', 'click', function(ev) {
  // 编辑
  var id = $(this).data('id');
  var $item = $('#media_' + id);
  console.log($item)
  var img = $item.attr('data-img'),
    email = $item.attr('data-email'),
    demand = $item.attr('data-demand'),
    demandName = $item.attr('data-demand-name'),
    message = $item.attr('data-message'),
    name = $item.attr('data-name');
  $('.popup-change-object').attr("data-id", id).removeClass('hide');
  var html ="<div class='body'><div class='avatar'><div class='avatar-mask' id='img-uploader' style='position: relative; z-index: 1;'><img src='" + img + "' alt=''></div></div><div class='line'><input type='text' placeholder='主体名称 如：好奇心日报' value='" + name + "' id='edit_media_name'></div><div class='line'><div class='input input-simulator' data-value='" + demand + "'><span>" + demandName + "</span><b class='littleSiggle'></b></div><div class='dropDown hide'><ul><li data-value='1'>自媒体配音 / 公众号</li><li data-value='2'>短视频配音 / 视频业</li><li data-value='3'>有声书配音 / 出版业</li><li data-value='4'>内容付费配音 / 文化</li><li data-value='5'>教材培训配音 / 课件</li><li data-value='6'>外语配音 / 英文</li><li data-value='7'>模仿配音 / 名人</li></ul></div></div><div class='line'><input type='text' placeholder='用于接受音频的邮箱地址' value='" + email + "' id='edit_media_email'></div><div class='line'><input type='text' placeholder='一句话简单介绍该主体' value='"  + message + "' id='edit_media_text'></div><div class='popup-footer'><a href='#' class='btn btn-black btn-confirm'>提交</a><a href='#' class='btn btn-normal close'>取消</a></div></div>";
  $('#popup-change-object .body').html(html);
  $('#popup-change-object .close').on('click', function () {
    $('.popup').addClass('hide');
  })
  $('#popup-change-object .btn-confirm').on('click', function () {
    editData.edit();
  })
  $('#popup-change-object .avatar-mask').click(function () {
    $('#img-uploader').trigger('click');
  })
  initSelector('.input-simulator');
})

// 上传信息
var editData = {
  uploading: false,
  getEditData: function () {
    return {
      id: $('#popup-change-object').attr('data-id'),
      token: localStorage.getItem('token'),
      media_name: $('#edit_media_name').val(),
      email: $('#edit_media_email').val(),
      media_pic: $('#popup-change-object .avatar img').prop('src'),
      media_message: $('#edit_media_text').val(),
      media_demand: $('#popup-change-object .input').attr('data-value')
    }
  },
  getCreateData: function () {
    return {
      registered: 0,
      wid: localStorage.getItem('wid'),
      media_name: $('#edit_media_name').val(),
      email: $('#edit_media_email').val(),
      media_type: 1,
      media_pic: $('#popup-change-object .avatar img').prop('src'),
      media_message: $('#edit_media_text').val(),
      media_demand: $('#popup-change-object .input').attr('data-value')
    }
  },
  edit: function () {
    var id = $('#popup-change-object').attr('data-id');
    var _this = this;
    if (!_this.uploading) {
      _this.uploading = true;
      // var api = 'http://testmedia.heardtech.com/Post/UpdateMedia',
      var api = apiCollect.apiMediaUpdate,
          data = _this.getEditData();
      $.post(api, data, function (data) {
        if (data.code == '000000') {
          _this.uploading = false;
          headtipObj2.show('修改成功');
          $('#popup-change-object').addClass('hide');
          var item = data.data;
          var html = "<td>" + item.media_name + "</td><td width='87'><span>" + item.media_demand_name + "</span></td><td>" + item.email + "</td><td><a href='#' class='btn btn-edit' data-id='"  + item.token_key + "'>编辑</a></td>";
          $('#media_' + id).html(html);
          var $tr = $('#media_' + id);
          $tr.html(html)
            .attr('data-img', item.media_pic)
            .attr('data-email', item.email)
            .attr('data-demand', item.media_demand)
            .attr('data-demand-name', item.media_demand_name)
            .attr('data-message', item.media_message)
            .attr('data-name', item.media_name);
        } else {
          headtipObj.show(data.message);
          _this.uploading = false;
        }
      })
    }
  },
  create: function () {
    var _this = this;
    if (!_this.uploading) {
      _this.uploading = true;
      // var api = 'http://testmedia.heardtech.com/Post/PostRegistered',
      var api = apiCollect.apiRegisterObject,
          data = _this.getCreateData();
      $.post(api, data, function (data) {
        if (data.code == '000000') {
          var item = data.data;
          _this.uploading = false;
          headtipObj2.show('新增成功 账户余额通用 订单/偏好独立');
          $('#popup-change-object').addClass('hide');
            var html = "<tr id='media_" + item.token_key + "' data-img='" + item.media_pic + "' data-email='" + item.email + "' data-demand='" + item.media_demand + "' data-demand-name='" + item.media_demand_name + "' data-message='" + item.media_message + "' data-name='" + item.media_name + "'><td>" + item.media_name + "</td><td width='87'><span>" + item.media_demand_name + "</span></td><td>" + item.email + "</td><td><a href='#' class='btn btn-edit' data-id='" + item.token_key + "'>编辑</a></td></tr>";
            $('.obj_set').append(html);
        } else {
          headtipObj.show(data.message);
          _this.uploading = false;
        }
      })
    }
  }
}

function initUploader(selector, container) {
  var Qn = new QiniuJsSDK();
  var uploader = Qn.uploader({
      runtimes: 'html5,flash,html4',
      browse_button: selector,
      // HTML中重要的div的ID
      container: container,
      drop_element: container,
      max_file_size: '500kb',
      dragdrop: false,
      chunk_size: '500kb',
      uptoken_url: apiCollect.apiQiniu,
      domain:"http://heard.qiniudn.com",
      get_new_uptoken: false,
      auto_start: true,
      log_level: 5,
      unique_names: true,
      save_key: false,
      init: {
          'FilesAdded': function(up, files) {
          },
          'BeforeUpload': function(up, file) {
          },
          'UploadProgress': function(up, file) {
          },
          'UploadComplete': function(up,files) {
          },
          'FileUploaded': function(up, file, info) {
            console.log($.parseJSON(info.response))
            var key=$.parseJSON(info.response).key;
            var pre = 'http://image.heardtech.com/'
            $('.popup-change-object>.inner .avatar-mask').html('<img src="' + pre + key + '">');
          },
          'Error': function(up, err, errTip) {
            headtipObj2.show(errTip);
          },
          'Key': function(up, file) {
          }

      },
      filters : {
          max_file_size : '500kb',
          mime_types: [
              //{title : "flv files", extensions : "flv"}, // 限定flv后缀上传格式上传
              // {title : "Audio files", extensions : "mp3"}// 限定flv,mpg,mpeg,avi,wmv,mov,asf,rm,rmvb,mkv,m4v,mp4后缀格式上传
              {title : "Image files", extensions : "jpg,gif,png,jpeg"}, // 限定jpg,gif,png后缀上传
              //{title : "Zip files", extensions : "zip"} // 限定zip后缀上传
          ]
      }
  })
}

initUploader('img-uploader', 'body');

function initSelector(selector) {
  var $input = $(selector);
  var $list = $input.siblings('.dropDown');
  $('.input-simulator').click(function () {
    // $list.removeClass('hide');
    if ($list.hasClass('hide')) {
      $list.removeClass('hide');
    } else {
      $list.addClass('hide');
    }
  });
  $list.find('li').click(function () {
    var value = $(this).data('value'),
      text = $(this).text();
    $list.addClass('hide');
    $input.attr('data-value', value).removeClass('placeholder').find('span').text(text);
  })
}

//openBill
var $billHead = $('.billHead');
var $billUl = $('#bill ul');
var $billHeadDivs = $billHead.children('div');
var $oneInp = $('.billContentOne input');
var $twoInp = $('.billContentTwo input');
var openBill = {
    allData:{
        invoicetitle:'',
        taxpayerid:'',
        regaddress:'',
        regtelephone:'',
        depositbank:'',
        bankaccount:'',
        mailingaddress:'',
        recipient:'',
        phone:'',
        wid: localStorage.getItem('wid'),
        type:'2'
    },
    otherData:{
        invoicetitle:'',
        taxpayerid:'',
        mailingaddress:'',
        recipient:'',
        phone:'',
        wid: localStorage.getItem('wid'),
        type:'1'
    },
    wid: localStorage.getItem('wid'),
    init: function () {
        var _this = this;
        // _this.pullBlance();
        $billHead.children('img').click(function (e) {
            e.stopPropagation();
            _this.close();
        });
        $('#off').click(function () {
            _this.close();
        });
        $('#ok').click(function () {
            _this.allData = {
                invoicetitle:$twoInp.eq(0).val(),
                taxpayerid:$twoInp.eq(1).val(),
                regaddress:$twoInp.eq(2).val(),
                regtelephone:$twoInp.eq(3).val(),
                depositbank:$twoInp.eq(4).val(),
                bankaccount:$twoInp.eq(5).val(),
                mailingaddress:$twoInp.eq(6).val(),
                recipient:$twoInp.eq(7).val(),
                phone:$twoInp.eq(8).val(),
                wid: localStorage.getItem('wid'),
                type:'2'
            };
            _this.otherData={
                invoicetitle:$oneInp.eq(0).val(),
                taxpayerid:$oneInp.eq(1).val(),
                mailingaddress:$oneInp.eq(2).val(),
                recipient:$oneInp.eq(3).val(),
                phone:$oneInp.eq(4).val(),
                wid: localStorage.getItem('wid'),
                type:'1'
            };
            _this.uploadingBillData();
            // _this.close();
        });
        _this.tabType();
        $('#openBill').click(function () {
            _this.show();
        });
    },
    show:function () {
        var _this = this;
        $('#bill').removeClass('none');
        $('#shade').removeClass('none')
    },
    close:function () {
        $('#bill').addClass('none');
        $('#shade').addClass('none')
    },
    tabType:function () {
        var _this = this;
        $.each($billHeadDivs,function (i,item) {
            $billHead.children('div').eq(i).click(function () {
                var $this = $(this);
                $this.css({
                    'borderBottom':'2px solid #191919',
                    'color':'#191919'
                }).siblings().css({
                    'border':'none',
                    'color':'#979797'
                });
                $billUl.eq(i).removeClass('none').siblings('ul').addClass('none');
                _this.allData.type = i+1;
                _this.otherData.type = i+1;
            })
        });
    },
    pullBlance:function () {
        var _this = this;
        $.post(apiCollect.apiBillBalance,{wid:_this.wid},function (data) {
            if (data.code == '000000'){
                $('.invoice').text(data.data.invoicemoney.toFixed(2)+' 元');
                console.log(data.data.invoicemoney.toFixed(2));
                $('#jine span').text(data.data.invoicemoney.toFixed(2));
            }else{
                headtipObj2.show(data.message)
            }
        })
    },
    uploadingBillData:function () {
        var _this = this;
        var dt ;
        if($('.billContentOne').hasClass('none')){
            dt = _this.allData;
            if(!_this.allData.invoicetitle){
                headtipObj2.show('纳税人名称/公司抬头不能为空')
            }else if(!_this.allData.taxpayerid){
                headtipObj2.show('纳税人识别号不能为空')
            }else if(!_this.allData.regaddress){
                headtipObj2.show('注册地址不能为空')
            }else if(!_this.allData.regtelephone){
                headtipObj2.show('注册电话不能为空')
            }else if(!_this.allData.depositbank){
                headtipObj2.show('开户银行不能为空')
            }else if(!_this.allData.bankaccount){
                headtipObj2.show('银行账户不能为空')
            }else if(!_this.allData.mailingaddress){
                headtipObj2.show('发票邮寄地址不能为空')
            }else if(!_this.allData.recipient){
                headtipObj2.show('发件人不能为空')
            }else if(!_this.allData.phone){
                headtipObj2.show('联系电话不能为空')
            }else {
                $.post(apiCollect.apiInvoice,dt,function (data) {
                    if (data.code == '000000'){
                        headtipObj2.show('开票成功')
                        $oneInp.val('');
                        $twoInp.val('');
                        _this.close();
                        _this.pullBlance()
                    }else {
                        headtipObj2.show(data.message)
                        _this.pullBlance()
                    }
                })
            }
        }else{
            dt = _this.otherData;
            if(!dt.invoicetitle){
                headtipObj2.show('纳税人名称/公司抬头不能为空')
            }else if(!dt.taxpayerid){
                headtipObj2.show('纳税人识别号不能为空')
            }else if(!dt.mailingaddress){
                headtipObj2.show('发票邮寄地址不能为空')
            }else if(!dt.recipient){
                headtipObj2.show('发件人不能为空')
            }else if(!dt.phone){
                headtipObj2.show('联系电话不能为空')
            }else {
                $.post(apiCollect.apiInvoice,dt,function (data) {
                    if (data.code == '000000'){
                        headtipObj2.show('开票成功')
                        $oneInp.val('');
                        $twoInp.val('');
                        _this.close();
                        _this.pullBlance()
                    }else {
                        headtipObj2.show(data.message);
                        _this.pullBlance()
                    }
                })
            }
        }

    }
};
openBill.init();

$('.billHead div').eq(1).click(function () {
    $('#bill').css('top','5%')
})
$('.billHead div').eq(0).click(function () {
    $('#bill').css('top','15%')
})
